package com.artezio.buyndrive.web;

import com.artezio.buyndrive.domain.Carservice;
import com.artezio.buyndrive.domain.Users;
import com.artezio.buyndrive.service.CarserviceService;
import com.artezio.buyndrive.service.CountryService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * User: spolyakov
 * Date: 25.07.12
 * Time: 10:21
 */

@Controller
public class AffiliatesController {

    protected final Log logger = LogFactory.getLog(AffiliatesController.class);

    @Autowired
    private CountryService countryService;

    @Autowired
    private CarserviceService carService;

    @RequestMapping("/affiliates")
    public ModelAndView affiliates(Map<String, Object> map,
                                   HttpServletRequest servletRequest,Model model) {

        model.addAttribute("user", new Users());
        model.addAttribute("carService", new Carservice());
        model.addAttribute("carServices", carService.getAll());
        model.addAttribute("country", countryService.getAll());

        logger.info("/affiliates");
        return new ModelAndView("affiliates");
    }

}
